/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.erp.client.widget;



import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FileUploadField;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;


/**
 *
 * @author Administrator
 */
public class myFileUpload extends LayoutContainer {

    public myFileUpload() {
        final Window w = new Window();
        w.setPlain(true);
        w.setSize(340, 260);
        w.setHeading("文档发布");
        w.setLayout(new FitLayout());
        final FormPanel panel = new FormPanel();
        panel.setHeading("请选择上传文件");
        panel.setFrame(true);

        panel.setEncoding(FormPanel.Encoding.MULTIPART);//multipart/form-data
        panel.setMethod(FormPanel.Method.POST);

        panel.setButtonAlign(HorizontalAlignment.CENTER);
        panel.setWidth(350);

        final FileUploadField fileUpload1 = new FileUploadField();
        fileUpload1.setName("文件1");
        fileUpload1.setFieldLabel("文件1");
        panel.add(fileUpload1);

        final FileUploadField fileUpload2 = new FileUploadField();
        fileUpload2.setName("文件2");
        fileUpload2.setFieldLabel("文件2");
        panel.add(fileUpload2);

        final FileUploadField fileUpload3 = new FileUploadField();
        fileUpload3.setName("文件3");
        fileUpload3.setFieldLabel("文件3");
        panel.add(fileUpload3);

        final FileUploadField fileUpload4 = new FileUploadField();
        fileUpload4.setName("文件4");
        fileUpload4.setFieldLabel("文件4");
        panel.add(fileUpload4);

        final FileUploadField fileUpload5 = new FileUploadField();
        fileUpload5.setName("文件5");
        fileUpload5.setFieldLabel("文件5");
        panel.add(fileUpload5);

        panel.setAction("com.erp.system/serverupload");
        //panel.setAction("com.erp.system/myfiledown");
        Button btn = new Button("上传");
        btn.addSelectionListener(new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
                
                if (!panel.isValid()) {
                    return;
                }
                panel.submit();
                Info.display("系统提示","文件传输成功！");
                //w.close();
            }
        });
        panel.addButton(btn);
        w.add(panel);
        w.show();
    }
}